@extends('layouts/app')

@section('content')
    <div class="comments">
        <div class="panel">
            <div class="shop-info row white-bg">
                <div class="col-2">
                    <img src="/img/eat.png" alt="" class="img-responsive">
                </div>
                <div class="col-10">
                    <div class="text">
                        <h3 class="f30 gary3 nowrap shop-name">店铺名称</h3>
                        <p class="f20 gary9 nowrap shop-note">店铺名称店铺名称店铺名称</p>
                    </div>
                </div>
            </div>
        </div>

        <div class="panel  white-bg">
            <div class="comment-stars row">
                <div class="col-3">
                    <p class="title  f30">综合评价：</p>
                </div>
                <div class="col-9">
                    <svg class="icon f48" aria-hidden="true">
                        <use xlink:href="#icon-star-fill"></use>
                    </svg>
                    <svg class="icon f48" aria-hidden="true">
                        <use xlink:href="#icon-star-fill"></use>
                    </svg>
                    <svg class="icon f48" aria-hidden="true">
                        <use xlink:href="#icon-star-fill"></use>
                    </svg>
                    <svg class="icon f48" aria-hidden="true">
                        <use xlink:href="#icon-star-fill"></use>
                    </svg>
                    <svg class="icon f48" aria-hidden="true">
                        <use xlink:href="#icon-star-fill"></use>
                    </svg>
                </div>
            </div>
        </div>

        <div class="panel white-bg">
            <div class="text-content">
                <textarea name="content" id="content"  rows="6" placeholder="口味如何？对包装还满意吗？（20字以上）"></textarea>
            </div>
        </div>

        <div class="bt padding">
            <a href="javascript:;" class="weui-btn weui-btn_primary f30 release">发布</a>
        </div>
    </div>


    <script>
        var sid = getRequest().sid,
            oid = getRequest().order_id;

        // 获取店铺信息
        function getShopsInfo () {
            $.get("/api/shopinfo", {id: sid}, function (res) {
                if (typeof res === 'string') {
                    res = JSON.parse(res);
                }

                console.log("res", res);
                $(".shop-name").text(res.data.shop_name);
                $(".shop-note").text(res.data.note);
            });
        }
        getShopsInfo();


        // 添加评论
        $(".release").click(function () {
            var data = {};
                data['shop_id'] = sid;
                data['order_id'] = oid;
                data['score'] = $(".comment-stars svg.orange").length;
                data['content'] = $("#content").val();



            if (!data['content'] || data['content'].length < 5) {
                return $.toast("评论内容不能少于5个字！", "text");
            }

            $.post("/api/shop/addcomment", data, function (res) {
                if (typeof res === 'string') {
                    res = JSON.parse(res);
                }

                $.alert(res.info, function () {
                    if (res.code == 200) {
                       history.go(-1);
                    }
                });
            });
        });
    </script>
@endsection

@extends('layouts/footer')
